﻿// (c) Copyright 2013 Mike Riedel.
// This source is subject to the Microsoft Public License (Ms-PL).
// All other rights reserved.

using System.IO;

namespace FreshMeat.Storage
{
   /// <summary>
   /// Provides serialization and deserialization via streams.
   /// Methods are thread safe.
   /// </summary>
   /// <typeparam name="T"></typeparam>
   public interface IStreamSerializer<T>
   {
      /// <summary>
      /// Serializes an object to a stream.
      /// Method is thread safe.
      /// </summary>
      /// <param name="item">Item to serialize.</param>
      /// <param name="output">Stream to write serialized data to.</param>
      void Serialize(T item, Stream output);

      /// <summary>
      /// Deserializes an object from a stream.
      /// Method is thread safe.
      /// </summary>
      /// <param name="input">The stream to read serialized data from.</param>
      /// <returns>The deserialized object.</returns>
      T Deserialize(Stream input);
   }
}